﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    ValidateRequest="false" CodeFile="Quiz.aspx.cs" Inherits="Admin_Quiz" Title="Admin Page - Information Literacy Education" %>

<%@ Register TagPrefix="uc" TagName="UpdateProgress" Src="~/UserControls/UpdateProgress.ascx" %>
<%@ Register TagPrefix="uc" TagName="ModalPopupMessage" Src="~/UserControls/ModalPopupMessage.ascx" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">
    <uc:UpdateProgress ID="updateProgress" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <uc:ModalPopupMessage ID="ModalPopupMessage" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <h1>
        Manage Learning Object Questions</h1>
    <br />
    <div style="padding-left: 10px;">
        <asp:Wizard ID="WizardQuiz" runat="server" ActiveStepIndex="0" CssClass="MinWidth"
            BackColor="White" Font-Names="Verdana" Font-Size="0.9em" DisplaySideBar="false"
            OnNextButtonClick="WizardQuiz_NextButtonClick" OnFinishButtonClick="WizardQuiz_FinishButtonClick">
            <StartNavigationTemplate>
                <div style="padding: 10px;">
                    <asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Start"
                        Width="100" ToolTip="Click this button to start!" />
                </div>
            </StartNavigationTemplate>
            <StepStyle Font-Size="1em" ForeColor="#000000" />
            <NavigationButtonStyle ForeColor="Black" CssClass="fancyButton" />
            <WizardSteps>
                <%--<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
                    <div style="padding: 10px;">
                        Welcome to Manage Quiz Questions.
                        <br />
                        This wizard will assist in adding, editing, and removing questions from a learning
                        object.
                    </div>
                </asp:WizardStep>--%>
                <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
                    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                        <ContentTemplate>
                            <div style="padding: 10px;">
                                Please choose a learning object you want to add or remove questions from the dropdowns
                                below.
                                <br />
                                <br />
                                <table class="table" style="min-width: 550px;">
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Module :
                                        </td>
                                        <td class="tableItem">
                                            <asp:DropDownList ID="ddlistStandards" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlistStandards_SelectedIndexChanged" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Learning Object :
                                        </td>
                                        <td class="tableItem">
                                            <asp:DropDownList ID="ddlistLearnObjs" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlistLearnObjs_SelectedIndexChanged" />
                                            &nbsp;<asp:RangeValidator ID="ValidatorLearnObj" runat="server" ControlToValidate="ddlistLearnObjs"
                                                Display="Dynamic" ErrorMessage="* Please Select a Learning Object" MaximumValue="100000"
                                                MinimumValue="1" SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
                                        </td>
                                    </tr>
                                    <%//REMOVED %>
                                    <tr style="display: none;">
                                        <td class="tableLeftHeader">
                                            Quiz Name :
                                        </td>
                                        <td class="tableItem">
                                            <asp:TextBox ID="txtQuizName" runat="server" Width="250" Enabled="false" BackColor="#EEEEEE" />
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3">

                    <script language="javascript" type="text/javascript">
                                    function MoveToNext()
                                    {
                                        var target = document.getElementById("ctl00_cphMain_WizardQuiz_StepNavigationTemplateContainerID_StepNextButton");
                                        target.click();
                                    }
                                    
                                    function MoveToPrev()
                                    {
                                        var target = document.getElementById("ctl00_cphMain_WizardQuiz_StepNavigationTemplateContainerID_StepPreviousButton");
                                        target.click();
                                    }
                    </script>

                    <h2>
                        <%=LearnObjTitle.ToString() %>
                    </h2>
                    <div style="width: 650px; overflow: visible; text-align: right;">
                        <input class="fancyButton" type="button" name="Prev" value="Previous" onclick="MoveToPrev()" />
                        &nbsp;&nbsp;
                        <input class="fancyButton" type="button" name="Next" value="Next" onclick="MoveToNext()" />
                    </div>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <div style="padding: 10px;">
                                <h3>
                                    Add Questions</h3>
                                <table>
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Questions:
                                        </td>
                                        <td class="tableItem">
                                            <asp:DropDownList ID="ddlistQuestionsList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlistQuestionsList_SelectedIndexChanged" />
                                        </td>
                                    </tr>
                                </table>
                                <!-- Tried to use ASP.NET functions but somehow it did not work that I used JavaScript. -->
                                <div style="min-width: 600px; margin-left: 50px; padding-bottom: 10px;">
                                    <b>Required by Default: </b>
                                    <asp:CheckBox ID="chkboxRequired" runat="server" />
                                    <br />
                                    <b>Excluded by Default: </b>
                                    <asp:CheckBox ID="chkboxExcluded" runat="server" />
                                    <ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender1"
                                        runat="server" TargetControlID="chkboxRequired" Key="QuestionEdit" />
                                    <ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender2"
                                        runat="server" TargetControlID="chkboxExcluded" Key="QuestionEdit" />
                                    <div style="display: none;">
                                        &nbsp;&nbsp;&nbsp; <b>Difficulty:</b>
                                        <asp:DropDownList ID="ddlistDifficulty" runat="server">
                                            <asp:ListItem Value="easy" Text="Easy" />
                                            <asp:ListItem Value="normal" Text="Normal" Selected="True" />
                                            <asp:ListItem Value="hard" Text="Hard" />
                                        </asp:DropDownList>
                                        &nbsp;&nbsp;&nbsp; <b>Point:</b>
                                        <asp:DropDownList ID="ddlistPoint" runat="server">
                                            <asp:ListItem Value="1" Text="1"></asp:ListItem>
                                            <asp:ListItem Value="2" Text="2" Selected="True"></asp:ListItem>
                                            <asp:ListItem Value="3" Text="3"></asp:ListItem>
                                        </asp:DropDownList>
                                    </div>
                                    <br />
                                    <br />
                                    <h4>
                                        Question:</h4>
                                    <FCKeditorV2:FCKeditor ID="txtQuestionText" runat="server" ToolbarSet="Basic" BasePath="~/fckeditor/"
                                        Height="150px" Width="420px" HtmlEncodeOutput="true">
                                    </FCKeditorV2:FCKeditor>
                                    <br />
                                    <b>Choice #1:</b><br />
                                    <div style="padding-left: 20px; margin-bottom: 10px;">
                                        <asp:TextBox ID="txtChoice1" runat="server" Width="400px" MaxLength="200" /><br />
                                        <asp:CheckBox ID="chkAnswer1" runat="server" Text="Is this a correct answer?" />
                                    </div>
                                    <b>Choice #2:</b><br />
                                    <div style="margin-left: 20px; margin-bottom: 10px;">
                                        <asp:TextBox ID="txtChoice2" runat="server" Width="400px" MaxLength="200" /><br />
                                        <asp:CheckBox ID="chkAnswer2" runat="server" Text="Is this a correct answer?" />
                                    </div>
                                    <b>Choice #3:</b><br />
                                    <div style="margin-left: 20px; margin-bottom: 10px;">
                                        <asp:TextBox ID="txtChoice3" runat="server" Width="400px" MaxLength="200" /><br />
                                        <asp:CheckBox ID="chkAnswer3" runat="server" Text="Is this a correct answer?" />
                                    </div>
                                    <b>Choice #4:</b><br />
                                    <div style="margin-left: 20px; margin-bottom: 10px;">
                                        <asp:TextBox ID="txtChoice4" runat="server" Width="400px" MaxLength="200" /><br />
                                        <asp:CheckBox ID="chkAnswer4" runat="server" Text="Is this a correct answer?" />
                                    </div>
                                    <b>Choice #5:</b><br />
                                    <div style="margin-left: 20px; margin-bottom: 10px;">
                                        <asp:TextBox ID="txtChoice5" runat="server" Width="400px" MaxLength="200" /><br />
                                        <asp:CheckBox ID="chkAnswer5" runat="server" Text="Is this a correct answer?" />
                                    </div>
                                    <br />
                                    <div style="margin-left: 30px;">
                                        <asp:Button ID="btnUpdateQuestion" runat="server" Text="Update Question" Width="200"
                                            OnClick="btnUpdateQuestion_Click" />
                                        &nbsp; <span style="font-size: 8pt; font-style: italic;">Update the question before
                                            adding a new question!</span>
                                        <br />
                                        <br />
                                        <asp:Button ID="btnAddNewQuestion" runat="server" Text="Add a New Question" Width="200"
                                            OnClick="btnAddNewQuestion_Click" />
                                        <br />
                                        <br />
                                        <br />
                                        <asp:Button ID="btnDeleteQuestion" runat="server" Text="Delete Question" Width="200"
                                            OnClick="btnDeleteQuestion_Click" />
                                        <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnDeleteQuestion"
                                            ConfirmText="Are you sure you want to delete the question?">
                                        </ajaxToolkit:ConfirmButtonExtender>
                                    </div>
                                </div>
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:PostBackTrigger ControlID="btnUpdateQuestion" />
                            <asp:PostBackTrigger ControlID="btnAddNewQuestion" />
                            <asp:PostBackTrigger ControlID="btnDeleteQuestion" />
                        </Triggers>
                    </asp:UpdatePanel>
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep4" runat="server" Title="Step 4">
                    <h2>
                        <%=LearnObjTitle.ToString() %>
                    </h2>
                    <div style="padding: 10px;">
                        You have created Learning Object Quiz Questions for
                        <asp:Label ID="lblResultLearnObjName" runat="server" /><br />
                        The list below contains all questions related to this learning object.<br />
                        <br />
                        <asp:XmlDataSource ID="XmlDataSourceQuestionsOverview" runat="server" XPath="quiz/questions/question" />
                        <asp:Repeater ID="RepeaterQuestionsOverview" runat="server" DataSourceID="XmlDataSourceQuestionsOverview">
                            <HeaderTemplate>
                                <table style="min-width: 560px; border-spacing: 0px;">
                                    <tr>
                                        <td class="tableTopHeader" style="width: 30px;">
                                            ID.
                                        </td>
                                        <td class="tableTopHeader" style="width: 40px;">
                                            Req.
                                        </td>
                                        <td class="tableTopHeader" style="width: 40px;">
                                            Excl.
                                        </td>
                                        <%---
                                        <td class="tableTopHeader" style="width: 30px;">
                                            Pt.
                                        </td>--%>
                                        <td class="tableTopHeader" style="width: 20px;">
                                        </td>
                                        <td class="tableTopHeader">
                                            Questions
                                        </td>
                                    </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr>
                                    <td style="text-align: center;">
                                        <%# XPath("@id") %>
                                    </td>
                                    <td style="text-align: center;">
                                        <asp:CheckBox ID="chkboxRequiredOverview" runat="server" CssClass="HiddenText" Checked='<%# Convert.ToBoolean(XPath("@defaultrequired").ToString()) %>'
                                            Enabled="false" />
                                    </td>
                                    <td style="text-align: center;">
                                        <asp:CheckBox ID="chkboxExcludedOverview" runat="server" CssClass="HiddenText" Checked='<%# Convert.ToBoolean(XPath("@excluded").ToString()) %>'
                                            Enabled="false" />
                                    </td>
                                    <%--
                                    <td style="text-align: center;">
                                        <%# XPath("@point") %>
                                    </td>--%>
                                    <td style="width: 20px;">
                                    </td>
                                    <td>
                                        <%# XPath("questiontext") %>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <%--
                                    <td>
                                    </td>--%>
                                    <td style="width: 20px;">
                                    </td>
                                    <td>
                                        <asp:Repeater ID="RepeaterChoices" runat="server" DataSource='<%# XPathSelect("choices/choice") %>'>
                                            <HeaderTemplate>
                                                <ul>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <li>
                                                    <%# XPath(".") %>
                                                    &nbsp;
                                                    <asp:Image ID="imgCorrectAnswer" runat="server" ImageUrl="~/Images/correct_answer.gif"
                                                        Visible='<%# Convert.ToBoolean(XPath("@iscorrectanswer").ToString()) %>' />
                                                </li>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </ul>
                                            </FooterTemplate>
                                        </asp:Repeater>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <AlternatingItemTemplate>
                                <tr style="background-color: #EEE;">
                                    <td style="text-align: center;">
                                        <%# XPath("@id") %>
                                    </td>
                                    <td style="text-align: center;">
                                        <asp:CheckBox ID="chkboxRequiredOverview" runat="server" CssClass="HiddenText" Checked='<%# Convert.ToBoolean(XPath("@defaultrequired").ToString()) %>'
                                            Enabled="false" />
                                    </td>
                                    <td style="text-align: center;">
                                        <asp:CheckBox ID="chkboxExcludedOverview" runat="server" CssClass="HiddenText" Checked='<%# Convert.ToBoolean(XPath("@excluded").ToString()) %>'
                                            Enabled="false" />
                                    </td>
                                    <%--
                                    <td style="text-align: center;">
                                        <%# XPath("@point") %>
                                    </td>--%>
                                    <td style="width: 20px;">
                                    </td>
                                    <td>
                                        <%# XPath("questiontext") %>
                                    </td>
                                </tr>
                                <tr style="background-color: #EEE;">
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <%--
                                    <td>
                                    </td>--%>
                                    <td style="width: 20px;">
                                    </td>
                                    <td>
                                        <asp:Repeater ID="RepeaterChoices" runat="server" DataSource='<%# XPathSelect("choices/choice") %>'>
                                            <HeaderTemplate>
                                                <ul>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <li>
                                                    <%# XPath(".") %>
                                                    &nbsp;
                                                    <asp:Image ID="imgCorrectAnswer" runat="server" ImageUrl="~/Images/correct_answer.gif"
                                                        Visible='<%# Convert.ToBoolean(XPath("@iscorrectanswer").ToString()) %>' />
                                                </li>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </ul>
                                            </FooterTemplate>
                                        </asp:Repeater>
                                    </td>
                                </tr>
                            </AlternatingItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                        <hr />
                        Click on the &quot;Previous&quot; button to modify question.
                        <br />
                    </div>
                </asp:WizardStep>
            </WizardSteps>
        </asp:Wizard>
    </div>
</asp:Content>
